package com.joysuch.wwyt.bp.controller;

import com.joysuch.wwyt.bp.bean.BpStoreAreaAddBean;
import com.joysuch.wwyt.bp.service.BpStoreAreaService;
import com.joysuch.wwyt.core.common.ajax.ResultBean;
import com.joysuch.wwyt.core.common.util.PageDataUtils;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@Api(tags = "设备设施管理-库区")
@RequestMapping("/bp/area")
public class BpStoreAreaController {


    @Autowired
    private BpStoreAreaService bpStoreAreaService;


    @GetMapping("page")
    public ResultBean page(Pageable page){
        page = PageDataUtils.addOrderByDesc(page, "id");
        return bpStoreAreaService.list(page);
    }

    @PostMapping("add")
    public ResultBean add(@RequestBody @Valid BpStoreAreaAddBean bpStoreArea){
        bpStoreAreaService.add(bpStoreArea);
        return ResultBean.defaultSuccessResult();
    }

    @PostMapping("edit")
    public ResultBean update(@RequestBody @Valid BpStoreAreaAddBean bpStoreArea){
        bpStoreAreaService.edit(bpStoreArea);
        return ResultBean.defaultSuccessResult();
    }

    @PostMapping("getById")
    public ResultBean getById(Long id){
        BpStoreAreaAddBean byId = bpStoreAreaService.getById(id);
        return ResultBean.wrapSuccessfulResult(byId);
    }








}
